<?php

/*
  // rme added
  $EmployeeUid = $_SESSION["EMPLOYEE"];

  $aux = explode ( '|', isset($_GET['id']) ? $_GET['id'] : '' );
  $JobUid = str_replace ( '"', '', $aux[0] );
  if (empty($JobUid)) $JobUid = $_SESSION["JOB"];
  $_SESSION["JOB"] = $JobUid;
  // rme end
*/
  try {

  $G_MAIN_MENU = 'processmaker';
  $G_SUB_MENU = 'hr/menuhrEmployee';
  $G_ID_MENU_SELECTED = 'ID_HR_EMP';
  $G_ID_SUB_MENU_SELECTED = 'ID_HR_JOBS';

  $G_PUBLISH = new Publisher;

  require_once ( PATH_PLUGINS . 'hr' . PATH_SEP . 'class.hr.php');
  $pluginObj = new hrClass ();

/*
  // rme added
  require_once ( "classes/model/HrEmployee.php" );
  $tr = HrEmployeePeer::retrieveByPK( $EmployeeUid  );

  if ( ( is_object ( $tr ) &&  get_class ($tr) == 'HrEmployee' ) ) {
    $fields00['EMPLOYEEFIRSTNAME'] = $tr->getEmployeefirstname() . " " . $tr->getEmployeelastname();
    $fields00['EMPLOYEESSN'] = $tr->getEmployeessn();
  } else
    $fields00 = array();

  $G_PUBLISH->AddContent('xmlform', 'xmlform', 'hr/hrEmployeeView', '', $fields00, '' );
  // rme end
*/

  require_once ( "classes/model/HrContracts.php" );
  require_once ( "classes/model/HrJobs.php" );

  $Criteria = new Criteria('workflow');
  $Criteria->clearSelectColumns ( );

  $Criteria->addSelectColumn (  HrContractsPeer::CONTRACT_UID );
  $Criteria->addSelectColumn (  HrContractsPeer::JOB_ID );
  $Criteria->addSelectColumn (  HrContractsPeer::TYPECONTRACT_ID );
  $Criteria->addSelectColumn (  HrContractsPeer::CONTRACTLENGTH_ID );
  $Criteria->addSelectColumn (  HrContractsPeer::STARTDATE );
  $Criteria->addSelectColumn (  HrContractsPeer::ENDDATE );
  $Criteria->addSelectColumn (  HrContractsPeer::ACTIVE );

  $Criteria->addSelectColumn (  HrJobsPeer::EMPLOYEE_ID );

//  $Criteria->addSelectColumn (  HrContractsPeer::RENEWALDATE );

  $Criteria->add (  hrContractsPeer::CONTRACT_UID, "xx" , CRITERIA::NOT_EQUAL );

  // rme added
  $Criteria->addJoin (  hrContractsPeer::JOB_ID, hrJobsPeer::JOB_UID );
  $Criteria->addDescendingOrderByColumn (  HrJobsPeer::EMPLOYEE_ID );
  // rme end

/*
  // rme added
  $Criteria->add (  hrContractsPeer::JOB_ID, $JobUid , CRITERIA::EQUAL );
  // rme end
*/

  $G_PUBLISH->AddContent('propeltable', 'paged-table', 'hr/hrContractsAllList', $Criteria , array(),'', '../../gulliver/propelTableAjax');
  G::RenderPage('publish', 'blank');

  }
  catch ( Exception $e ) {
    $G_PUBLISH = new Publisher;
    $aMessage['MESSAGE'] = $e->getMessage();
    $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
    G::RenderPage( 'publish', 'blank' );
  }
